﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using CapaEntidades;

namespace CapaDatos
{
    public class daSegmento
    {
        public static List<enSegmento> segmentoListar() {

            SqlConnection cn = null;
            SqlCommand cmd = null;
            SqlDataReader dr = null;
            List<enSegmento> lstSegmento = null;
            try
            {
                cn = Conexion.getConexion();
                cmd = new SqlCommand("select * from VE_segmento", cn);
                cmd.CommandType = CommandType.Text;
                cn.Open();
                dr = cmd.ExecuteReader();
                lstSegmento = new List<enSegmento>();
                while (dr.Read())
                {
                    enSegmento segmento = new enSegmento();
                    segmento.seg_id = Convert.ToInt32(dr[0].ToString());
                    segmento.seg_descripcion = dr[1].ToString();
                    lstSegmento.Add(segmento);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                dr.Close();
                cn.Close();
            }
            return lstSegmento;
        
        }
    }
}
